<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>前端不定向水平居中</title>
    <style>
        body,
        div,
        dl,
        dt,
        dd,
        ul,
        ol,
        li,
        h1,
        h2,
        h3,
        h4,
        h5,
        h6,
        pre,
        code,
        form,
        fieldset,
        legend,
        input,
        button,
        textarea,
        p,
        blockquote,
        th,
        td {
            margin: 0;
            padding: 0;
        }

        body {
            background: #fff;
            color: #555;
            font-size: 14px;
            font-family: Verdana, Arial, Helvetica, sans-serif;
        }

        td,
        th,
        caption {
            font-size: 14px;
        }

        h1,
        h2,
        h3,
        h4,
        h5,
        h6 {
            font-weight: normal;
            font-size: 100%;
        }

        address,
        caption,
        cite,
        code,
        dfn,
        em,
        strong,
        th,
        var {
            font-style: normal;
            font-weight: normal;
        }

        a {
            color: #555;
            text-decoration: none;
        }

        a:hover {
            text-decoration: underline;
        }

        img {
            border: none;
        }

        ol,
        ul,
        li {
            list-style: none;
        }

        input,
        textarea,
        select,
        button {
            font: 14px Verdana, Helvetica, Arial, sans-serif;
        }

        table {
            border-collapse: collapse;
        }

        html {
            overflow-y: scroll;
        }

        .clearfix:after {
            content: ".";
            display: block;
            height: 0;
            clear: both;
            visibility: hidden;
        }

        .clearfix {
            *zoom: 1;
        }

        .page {
            width: 500px;
            /* height: 20px; */
            /* border: 1px solid #ddd; */
            margin: 10px auto 0px;
            /* page里面的内容要水平显示 */
            text-align: center;

        }

        .page a,
        .page span {

            /* 行内块元素，给宽高有用 */
            display: inline-block;
            /* width: 30px; */
            height: 20px;
            line-height: 20px;
            border: 1px solid #ddd;
            padding: 0px 8px;
            /* 使用padding而不使用width是因为盒子大小固定了，里面的内容不固定就很容易导致显示不全,padding就直接固定了和边框的位置，盒子大小也会自己变动 */
        }

        .page span {
            background-color: red;
        }
    </style>
</head>

<body>
    <div class="page">
        <a href="#">&lt;</a>
        <span>1</span>
        <a href="#">2ff222</a>
        <a href="#">3</a>
        <a href="#">4</a>
        <a href="#">5</a>
        <a href="#">6</a>
        <a href="#">7</a>
        <a href="#">100</a>
        <a href="#">&gt;</a>
    </div>
</body>

</html>